﻿import com.dmotiko.mirador.*
import com.dmotiko.general.*
import mx.transitions.*
import mx.transitions.easing.*
import mx.utils.Delegate;

class MiradorEventosNavBar
extends BaseClip {
	private var mcEventos:MiradorInternalBtn;
	private var mcServiciosAdicionales:MiradorInternalBtn;
	private var mcPQ:MiradorInternalBtn;
	private var mcClientes:MiradorInternalBtn;
	private var lastBtn:MiradorInternalBtn;
		
	public function childLoaded( e ):Void {
		switch (e.target ) {
			case mcEventos:
			mcEventos.setData(MiradorServiciosEventos.EVENTOS);
			mcEventos.addEventListener( BaseClipEvent.CHANGED, Delegate.create(this, btn_changed ));
			mcEventos.onRollOver();
			mcEventos.onRelease();
			break;
			
			case mcServiciosAdicionales:
			mcServiciosAdicionales.setData(MiradorServiciosEventos.SERVICIOS);
			mcServiciosAdicionales.addEventListener( BaseClipEvent.CHANGED, Delegate.create(this, btn_changed ));
			break;
			
			case mcPQ:
			mcPQ.setData(MiradorServiciosEventos.POR_QUE);
			mcPQ.addEventListener( BaseClipEvent.CHANGED, Delegate.create(this, btn_changed ));
			break;
			
			case mcClientes:
			mcClientes.setData(MiradorServiciosEventos.CLIENTES);
			mcClientes.addEventListener( BaseClipEvent.CHANGED, Delegate.create(this, btn_changed ));
			break;
		}
		
	}
	
	private function btn_changed( e ):Void	{
		if ( lastBtn == e.target) return;
		lastBtn.setActive(false, false);
		e.target.setActive(true);
		lastBtn = e.target;
		this.dispatchEvent( { type: BaseClipEvent.CHANGED, target: this, data: e.data } );
	}
		
}